<?php 
	echo '<p>Hello World</p>'; 
	
//	$json = '{"a": 1, "b": 2, "c": 3, "d": 4, "e": 5}, {"a":11, "b":22, "c":33, "d":44, "e":55}';
	//$json = '{"a": 1, "b": 2, "c": 3, "d": 4, "e": 5}';
	$json = '[{"a":}]';
	//$json = "";
	
	//[a-zA-Z]
	
	
	$url = "http://128.199.213.71:9292/instruments";
	
	function getInstruments($url) {
		$jobj = @file_get_contents($url);
		
		// bad request, error 400
		if($jobj == FALSE) {
			echo 'market is closed <br />';
			return 'market is closed <br />';
		} else {
		// testing
			$obj = json_decode($json);
			var_dump($json);
			if(empty($json)) {
				echo 'no market info';
				return 'no market info';
			}
			//echo $obj->{"b"};
			
			if(empty($json) || (strpos($json,'[') == false and strpos($json,']') !== false)) {
				echo 'no market info';
				return 'no market info';
			}
			
				// complete lack of info
			foreach( $obj as $key => $value ) {
				echo "$key: $value<br/>\n";
				//print $item;
			}
		}
	}
	
	
	
	$obj = json_decode($json);
		
		// contains {} 
		if(empty($json) || (strpos($json,'[') == false and strpos($json,']') !== false)) {
			echo 'no market info';
		}
	
	
	
?> 